<!DOCTYPE html  >
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <meta content="no-cache" http-equiv="pragma"/>
    <meta content="no-cache" http-equiv="cache-control"/>
    <meta content="0" http-equiv="expires"/>
    <!-- 管局要求保持备案名称和网站使用名称一致 -->
    <title>当代中国研究所OA系统</title>
    <link rel="shortcut icon" th:href="@{/y9static/y9-ddyjs/img/logo-1.svg}" type="image/x-icon"/>
    <link rel="stylesheet" th:href="@{/y9static/y9-ddyjs/layui/css/layui.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/y9static/y9-ddyjs/css/default.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/y9static/y9-ddyjs/css/styles.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/y9static/y9-ddyjs/css/mediaIndex.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/y9static/y9-ddyjs/css/loaders.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/y9static/y9-ddyjs/css/layerMsg.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/y9static/y9-ddyjs/css/verify.css}" type="text/css"/>
    <script charset="utf-8" th:src="@{/y9static/js/base64.js}" type="text/javascript"></script>
    <script charset="utf-8" th:src="@{/y9static/y9-ddyjs/js/jquery-2.1.1.min.js}" type="text/javascript"></script>
    <script charset="utf-8" th:src="@{/y9static/js/jquery/jquery.cookie.js}" type="text/javascript"></script>
    <script charset="utf-8" th:src="@{/y9static/y9-ddyjs/js/jsencrypt.min.js}" type="text/javascript"></script>
    <script charset="utf-8" th:src="@{/y9static/y9-ddyjs/layui/layui.js}" type="text/javascript"></script>
    <script charset="utf-8" th:src="@{/y9static/y9-ddyjs/js/layerMsg.js}" type="text/javascript"></script>
</head>
<body>
<div class="logo">
    <img th:src="@{/y9static/y9-ddyjs/img/logo.svg}">
</div>
<div class="login">
    <div class="layui-row">
        <div class="layui-col-xs6 login_form" id="tunnel">
            <div class="login_title">
                <span>用户登录</span>
            </div>
            <div class="login_fields">
                <form id="fm1" method="post" th:object="${credential}">
                    <div class="alert alert-danger" th:if="${#fields.hasErrors('*')}">
                        登录失败：<span th:each="err : ${#fields.errors('*')}" th:utext="${err}"/>
                    </div>
                    <div class="login_fields__user">
                        <div class="icon"><img alt="" th:src="@{/y9static/y9-ddyjs/img/user.svg}"/></div>
                        <span class="icon-1">|</span>>
                        <input autocomplete="off" id="username" onBlur="inputOnBlur();" placeholder="请输入账号"
                               type="text"
                               value=""/>
                        <input autocomplete="false" htmlescape="true" id="username1" name="username"
                               style="width: 150px;"
                               tabindex="1" type="hidden"/>
                        <input autocomplete="false" htmlescape="true" id="tenantShortName" name="tenantShortName"
                               style="width: 150px;" type="hidden" value="default"/>
                        <div class="validation"><img alt="" th:src="@{/y9static/y9new/img/tick.png}"/></div>
                    </div>
                    <div class="login_fields__password">
                        <div class="icon"><img alt="" th:src="@{/y9static/y9-ddyjs/img/pwd.svg}"/></div>
                        <span class="icon-1">|</span>>
                        <input autocomplete="off" htmlescape="true" id="password" onfocus="this.type='password'"
                               placeholder="请输入密码"
                               tabindex="2" type="text"/>
                        <input autocomplete="off" htmlescape="true" id="password1" name="password" type="hidden"/>

                        <div class="validation"><img alt="" th:src="@{/y9static/y9-ddyjs/img/tick.png}"/></div>
                    </div>
                    <!-- 表单隐藏数据块开始 -->
                    <input id="loginType" name="loginType" type="hidden" value="loginName"/>
                    <input id="captchaKey" name="captchaKey" type="hidden" value=""/>
                    <input id="noLoginScreen" name="noLoginScreen" type="hidden" value="false"/>
                    <input id="screenDimension" name="screenDimension" type="hidden" value=""/>
                    <input id="pwdEcodeType" name="pwdEcodeType" type="hidden" value=""/>
                    <input name="execution" th:value="${flowExecutionKey}" type="hidden"/>
                    <input name="_eventId" type="hidden" value="submit"/> <input name="geolocation" type="hidden"/>
                    <!-- 表单隐藏数据块结束 -->
                </form>
                <!--点选验证码  -->
                <div id="mpanel6"></div>
                <div class="login_fields__submit">
                    <input type="button" value="登录"/>
                </div>
            </div>
            <div></div>

            <div class="success"></div>
            <div class="toolTips" style="display: none">
                <ul id="toolTipsUl"></ul>
            </div>
        </div>
        <div class="layui-col-xs6 noticeInfo">
            <div class="title">温馨提示</div>
            <div class="info">
                <span>1、本系统为非涉密系统，请勿上传涉密文件，请勿将标密文件、电报掩盖密级扫描上传；要求按密件上报的报告请走线下纸质渠道上报。</span>
                <span>2、不要在公共场合保存登录信息</span>
                <span>3、尽量避免多人使用同一账号</span>
                <span>4、为保证您的账户安全，退出时请注销，并定期修改密码</span>
            </div>
        </div>
    </div>
</div>
<!--<div class="bg_top_right"></div>-->
<script type="text/javascript">
    var ctx = "[(${#request.getContextPath()})]";
    var canGetCookie = 1; //是否支持存储Cookie 0 不支持 1 支持
    var ajaxmockjax = 1; //是否启用虚拟Ajax的请求响 0 不启用  1 启用
    var inputTimer = null;
    $(function () {
        validateIE();
    });

    function validateIE() {
        try {
            $("#screenDimension").val(window.screen.width + '*' + window.screen.height);
        } catch (e) {
        }
    }

    function inputOnBlur() {
        $("#username1").val($("#username").val());
    }

    function mouseClickEvent() {
        $('#tenantShortName').val(this.id);
        var userName = this.innerText;
        $('#username').val(userName);
        if ($.trim(userName).length > 0 && userName.indexOf("@") != -1) {
            $('#username1').val(userName.split("@")[0]);
        }
        $("#toolTipsUl").empty();
        $(".toolTips").attr({style: "display: none;"});
        $('#password').focus();
    }

    $(document).keydown(function (e) {
        // 上下选择事件
        function shooseItem(value) {
            let activeIndex = null, lisLength = $("#toolTipsUl").children().length;
            lisLength &&
            $("#toolTipsUl li").each(function (index, element) {
                if (this.className.includes("active")) {
                    this.className = "";
                    activeIndex = index;
                    return true;
                }
            });

            if (!lisLength && activeIndex === null) {
                return false;
            }
            if (value === 38 && activeIndex) {
                $("#toolTipsUl").children().eq(activeIndex - 1).addClass("active");
                return true;
            }
            if (value === 38 && !activeIndex) {
                $("#toolTipsUl").children().eq(lisLength - 1).addClass("active");
                return true;
            }
            if (value === 40 && (activeIndex === null || activeIndex + 1 === lisLength)) {
                $("#toolTipsUl").children().eq(0).addClass("active");
                return true;
            }
            if (value === 40 && activeIndex + 1 <= lisLength) {
                $("#toolTipsUl").children().eq(activeIndex + 1).addClass("active");
                return true;
            }
        }

        // 回车键事件
        if (e.which === 13) {
            enterEvent();
        }
        // 上下按键
        if (e.which === 38 || e.which === 40) {
            e.which === 38 && shooseItem(38);
            e.which === 40 && shooseItem(40);
        }
    });

    function enterEvent() {
        let shoseEvent = false;
        $("#toolTipsUl").children().length && $("#toolTipsUl li").each(function (index, element) {
            if (this.className.includes("active")) {
                shoseEvent = true;
                $('#tenantShortName').val(this.id);
                var userName = this.innerText;
                $('#username').val(userName);
                if ($.trim(userName).length > 0 && userName.indexOf("@") != -1) {
                    $('#username1').val(userName.split("@")[0]);
                }
                $("#toolTipsUl").empty();
                $(".toolTips").attr({style: "display: none;"});
                $('#password').focus();
                return true;
            }
        });
        if (!shoseEvent) {
            $('input[type="button"]').click();
        }
    }

    var open = 0;
    layui.use("layer", function () {
        var option = {
            type: "success",
            position: "top-center",
            showicon: true,
            time: 3000,
            title: "登录提示",
            content: "提示",
            shadow: false,
            shadowclickclose: true,
            autoclose: true,
            callback: function (data, obj) {
                obj.ele.close(0);
            },
        };
        //非空验证
        $('input[type="button"]').click(function () {
            var username = $('#username').val();
            var username1 = $('#username1').val();
            var password = $('#password').val();
            var tenantShortName = $("#tenantShortName").val();
            if (username == "") {
                option.type = "warn";
                option.content = "请输入您的账号";
                WfMsg(option);
            } else if (password == "") {
                option.type = "warn";
                option.content = "请输入密码";
                WfMsg(option);
            } else {
                $.when(
                    $.ajax({
                        async: false,
                        cache: false,
                        type: "GET",
                        url: ctx + '/api/getRandom',
                        dataType: "json",
                        success: function (y9Result) {
                            if (y9Result.success) {
                                $('#pwdEcodeType').val(y9Result.data);
                            }
                        }
                    })
                ).done(function () {
                    $.ajax({
                        async: false,
                        cache: false,
                        type: "POST",
                        url: ctx + '/api/checkSsoLoginInfo',
                        data: {
                            username: encode64(username1),
                            password: encrypt($('#pwdEcodeType').val(), encode64(password)),
                            tenantShortName: tenantShortName,
                            pwdEcodeType: $('#pwdEcodeType').val()
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $("#mpanel6").attr({style: "display: block;"});
                            } else {
                                var msg = data.msg;
                                if (msg != null && msg.length > 0) {
                                    option.type = "warn";
                                    option.content = msg;
                                    WfMsg(option);
                                }
                            }
                        }
                    })
                }).fail(function () {
                    option.type = "warn";
                    option.content = "获取随机数失败。";
                    WfMsg(option);
                });
            }
        });
    });
    //全屏
    var fullscreen = function () {
        elem = document.body;
        if (elem.webkitRequestFullScreen) {
            elem.webkitRequestFullScreen();
        } else if (elem.mozRequestFullScreen) {
            elem.mozRequestFullScreen();
        } else if (elem.requestFullScreen) {
            elem.requestFullscreen();
        } else {
            //浏览器不支持全屏API或已被禁用
        }
    };
</script>
<script charset="utf-8" th:src="@{/y9static/y9-ddyjs/js/verify.js}" type="text/javascript"></script>
</body>
</html>